<script setup lang="ts" name="TitleBar">
import { TitleBarProperty } from './config'

/** 标题栏 */

defineProps<{ property: TitleBarProperty }>()
</script>

<template>
  <div class="title-bar">
    <el-image v-if="property.bgImgUrl" :src="property.bgImgUrl" fit="cover" class="w-full" />
    <div class="absolute left-0 top-0 w-full">
      <!-- 标题 -->
      <div
        v-if="property.title"
        :style="{
      fontSize: `${property.titleSize}px`,
      fontWeight: property.titleWeight,
      color: property.titleColor,
      textAlign: property.textAlign
    }">
        {{ property.title }}
      </div>
      <!-- 副标题 -->
      <div
        v-if="property.description"
        :style="{
      fontSize: `${property.descriptionSize}px`,
      fontWeight: property.descriptionWeight,
      color: property.descriptionColor,
      textAlign: property.textAlign
    }"
        class="m-t-8px">
        {{ property.description }}
      </div>
    </div>
    <!-- 更多 -->
    <div
      v-show="property.more.show"
      class="more"
      :style="{
      color: property.descriptionColor
    }">
      <span v-if="property.more.type !== 'icon'"> {{ property.more.text }} </span>
      <SvgIcon v-if="property.more.type !== 'text'" icon="ep:arrow-right" />
    </div>
  </div>
</template>

<style scoped lang="scss">
.title-bar {
  position: relative;
  width: 100%;
  min-height: 20px;
  box-sizing: border-box;

  /* 更多 */
  .more {
    position: absolute;
    top: 0;
    right: 8px;
    bottom: 0;
    display: flex;
    margin: auto;
    font-size: 10px;
    color: #969799;
    align-items: center;
    justify-content: center;
  }
}
</style>
